<?php
/*
 * Created on Jul 9, 2009
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
/**
 * @filesource /modules/user/Form/Register.php
 * @abstract Generate a register form, where no lable is set
 *     see /modules/user/views/register/register.phtml for how the form is generated.
 */
class user_Form_SearchUser extends Zend_Form
{

    protected $_noDecorator = array(
        'ViewHelper', 
        'Errors'
    );

    public function cluBuild($params)
    {
        // set the method for the display form to POST
//        $actionSearchForm = $params['view']->hvnUrl(array('module' => 'user', 'action'=>'search'), 'nocontroller');
//        $this->setAction($actionSearchForm);
        //$this->setMethod('POST');
		//$this->setAction('user/search/search');

    	$this->setAction($params['action_url']);
    	
		//common filters & validators for all fields
        $filterTrim = new Zend_Filter_StringTrim();
        
        //no-special-character validator
        $nscValidator = new Zend_Validate_Regex('/^[,A-Z0-9_\s\-]*$/i'); //alpha, num, space, -, _
        $nscValidator->setMessage(t(60), Zend_Validate_Regex::NOT_MATCH);
        
        $validatorNotEmpty = new Zend_Validate_NotEmpty();
        $validatorNotEmpty->setMessage(t(418));


        // id
        $userId = new Zend_Form_Element_Text('id',  array('disableLoadDefaultDecorators' => true,
                                                                 'class' => 'inputText'));
        $userId->addDecorators($this->_noDecorator);
        $this->addElement($userId);
        
        //User name
        $userName = new Zend_Form_Element_Text('name', 
                         array('disableLoadDefaultDecorators' => true,
                               'class' => 'inputText'));
        
        $userName->addDecorators($this->_noDecorator)
              ->addValidator($nscValidator);
        $this->addElement($userName);
        
        //mail
        $mail = new Zend_Form_Element_Text('email', 
                         array('disableLoadDefaultDecorators' => true,
                               'class' => 'inputText'));
        $validatorEmail = new Zend_Validate_EmailAddress();
        $validatorEmail->setMessages(
            array(
                Zend_Validate_EmailAddress::INVALID            => t(743),
                Zend_Validate_EmailAddress::INVALID_HOSTNAME   => t(744),
        ));

        $mail->addValidator($validatorNotEmpty, false)
              ->addFilter($filterTrim)
              ->addValidator($validatorEmail)
              ->addDecorators($this->_noDecorator);
        $this->addElement($mail);
        
        
        //status
        $status = new Zend_Form_Element_Select('status',  array('disableLoadDefaultDecorators' => true,
                                                                 'required' => false));
        $status->addMultiOption('all', 'All')
        		->addMultiOption('1', 'Activated')
        		->addMultiOption('0', 'No Activated');
        $status->addDecorators($this->_noDecorator);
        $this->addElement($status);
        

        //Roles
        $role = new Zend_Form_Element_Text('role', 
                         array('disableLoadDefaultDecorators' => true,
                               'class' => 'inputText'));
        
        $role->addDecorators($this->_noDecorator);
        $this->addElement($role);
        
        // add the submit button
        $submit = new Zend_Form_Element_Submit('submit', array('disableLoadDefaultDecorators' => true, 
                                                               'label' => t(67) ));
        $submit->addDecorators($this->_noDecorator);
        $this->addElement($submit);

    }
}

?>